import { createRouter, createWebHistory } from 'vue-router'
import Layout from '../Layout/index.vue'

const routes = [
    {
        path: '/',
        redirect: '/dashboard'
    },
    {
        path: '/',
        name: 'home',
        component: Layout,
        children: [
            {
                path: '/dashboard',
                name: 'dashboard',
                meta: {
                    title: '系统首页',
                },
                component: () => import('@/views/dashboard.vue')
            }, {
                path: '/baseTable',
                name: 'baseTable',
                meta: {
                    title: '表格'
                },
                component: () => import('@/views/baseTable.vue')
            }, {
                path: '/baseCharts',
                name: 'baseCharts',
                meta: {
                    title: '图表'
                },
                component: () => import('@/views/baseCharts.vue')
            }, {
                path: '/form/baseForm',
                name: 'baseForm',
                meta: {
                    title: '表单'
                },
                component: () => import('@/views/form/baseForm.vue')
            }, {
                path: '/form/upload',
                name: 'upload',
                meta: {
                    title: '文件上传'
                },
                component: () => import('@/views/form/upload.vue')
            },

            {
                path: '/form/form-2/editor',
                name: 'editor',
                meta: {
                    title: '富文本编辑器'
                },
                component: () => import('@/views/form/threeMenu/editor.vue')
            }, {
                path: '/form/form-2/markdown',
                name: 'markdown',
                meta: {
                    title: 'markdown编辑器'
                },
                component: () => import('@/views/form/threeMenu/markdown.vue')
            },

            {
                path: '/org/demo/index',
                name: "demo",
                meta: {
                    title: '组织机构逻辑'
                },
                component: () => import('@/views/org/demo/index.vue')
            },
            {
                path: '/org/userdepManage/index',
                name: "userdepManage",
                meta: {
                    title: '用户部门管理'
                },
                component: () => import('@/views/org/userdepManage/index.vue')

            },
            {
                path: '/org/menuManage/index',
                name: "menuManage",
                meta: {
                    title: '菜单管理'
                },
                component: () => import('@/views/org/menuManage/index.vue')

            },
            {
                path: '/org/roleManage/index',
                name: "roleManage",
                meta: {
                    title: '角色管理'
                },
                component: () => import('@/views/org/roleManage/index.vue')

            },
            {
                path: '/org/postManage/index',
                name: "postManage",
                meta: {
                    title: '岗位管理'
                },
                component: () => import('@/views/org/postManage/index.vue')

            },
            {
                path: '/tabs',
                name: 'tabs',
                meta: {
                    title: 'tab标签'
                },
                component: () => import('@/views/tabs.vue')
            }, {
                path: '/i18n',
                name: 'i18n',
                meta: {
                    title: '国际化语言'
                },
                component: () => import('@/views/i18n.vue')
            }, {
                path: '/icon',
                name: 'icon',
                meta: {
                    title: '自定义图标'
                },
                component: () => import('@/views/icon.vue')
            },
            {
                path: '/schart',
                name: 'schart',
                meta: {
                    title: 'schart图表'
                },
                component: () => import('@/views/baseCharts.vue')
            },
            {
                path: '/error/404',
                name: '404',
                meta: {
                    title: '找不到页面'
                },
                component: () => import('@/views/error/404.vue')
            }, {
                path: '/error/403',
                name: '403',
                meta: {
                    title: '没有权限'
                },
                component: () => import('@/views/error/403.vue')
            }
        ]
    },
    {
        path: '/login',
        name: 'login',
        meta: { title: '登录' },
        component: () => import('@/views/login/Index.vue')
    },
    {
        path:'/404',
        name:'404',
        component:() => import('@/views/error/404.vue')
    },
    {
        path:'/403',
        name:'403',
        component:() => import('@/views/error/403.vue')
    },
    { path: '/:pathMatch(.*)*', redirect: '/404', hidden: true } // 添加404重定向，防止用户随意敲链接
]


const router = createRouter({
    history: createWebHistory(),
    routes
})

export default router